<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Amber - Pet Care Bootstrap 5 Template</title>

		<!-- Favicons -->
		<link rel="shortcut icon" href="assets/images/favicon.ico">

		<link rel="stylesheet" href="assets/css/vendor/vendor.min.css">
		<link rel="stylesheet" href="assets/css/plugins/plugins.min.css">
		<link rel="stylesheet" href="assets/css/style.min.css">
		<link rel="stylesheet" type="text/css" href="assets/css/page.css"/>
	</head>
<!-- jquery -->
	<script src="assets/jquery-3.6.0.min.js"></script>
	<script type="text/javascript">
		<!-- 导航栏的JS-开始 -->
		var host = "http://localhost:8083"
		//文档就绪
		$(function(){
			getItemCat();
		})
		//获取二级分类菜单，循环遍历添加菜单
		function getItemCat(){
			$.ajax({
				type:"get",
				url: host + "/itemCat/getAll",
				success: function(result){
					if(result.status == 200){
						//console.log(result.data)
						var itemCatList = result.data
						//遍历一级分类菜单
						for(var i in itemCatList){
							var itemCatOne = itemCatList[i]
							var itemCatOneChildren = itemCatOne.children
							//遍历二级分类菜单
							if(i==0){
								for(var j in itemCatOneChildren){
									var itemCatTwo = itemCatOneChildren[j]
									$("#dog").append(
										`
											<li><a class="a" onclick="dogItem(${itemCatTwo.id})">${itemCatTwo.name}</a></li>
										`
									)
								}
							}
							if(i==1){
								for(var j in itemCatOneChildren){
									var itemCatTwo = itemCatOneChildren[j]
									$("#cat").append(
										`
											<li><a class="a" onclick="catItem(${itemCatTwo.id})">${itemCatTwo.name}</a></li>
										`
									)
								}
							}
							if(i==2){
								for(var j in itemCatOneChildren){
									var itemCatTwo = itemCatOneChildren[j]
									$("#other").append(
										`
											<li><a class="a" onclick="otherItem(${itemCatTwo.id})">${itemCatTwo.name}</a></li>
										`
									)
								}
							}
						}
					}					
				}
			})
		}
		//点击狗狗分类的某一个二级菜单，会获取item表中item_cat_id为此id的商品，并显示在shop.html页面
		function dogItem(id){
			$.ajax(host+`/item/getData/${id}`)
			window.location.href="shop.html"
		}
		//点击猫咪分类的某一个二级菜单，会获取item表中item_cat_id为此id的商品，并显示在shop.html页面
		function catItem(id){
			$.ajax(host+`/item/getData/${id}`)
			window.location.href="shop.html"
		}
		//点击其他分类的某一个二级菜单，会获取item表中item_cat_id为此id的商品，并显示在shop.html页面
		function otherItem(id){
			$.ajax(host+`/item/getData/${id}`)
			window.location.href="shop.html"
		}
		//点击搜索框触发
		function searchItem(){
			let keyword = $("#search").val()
			$.ajax({
				type: "get",
				url: host+"/item/search",
				data: {
					keyword:keyword
				},
				success: function(result){
					if(result.status==200){
						window.location.href = "shop.html"
					}
				}
			})
		}
		//退出登录
		function logout(){
			$.ajax({
				type: "post",
				url: host+"/auth/logout",
				success: function(result){
					if(result.status == 200){
						alert("退出登录成功")
						window.location.href = "index.html"
					}else{
						alert("您还没有登录")
					}
				}
			})	
		}
		/* 登录认证，如果没有登录，就不会跳转到account.html页面 */
		function accountAuth(){
			$.ajax({
				type: "get",
				url: host+"/auth/getAuth",
				success: function(result){
					if(result.status == 200){
						window.location.href = "account.html"
					}else{
						alert("您还没有登录")
					}
				}
			})
		}
		/* 登录认证，如果没有登录，就不会跳转到cart.html页面 */
		function cartAuth(){
			$.ajax({
				type: "get",
				url: host+"/auth/getAuth",
				success: function(result){
					if(result.status == 200){
						window.location.href = "cart.html"
					}else{
						alert("您还没有登录")
					}
				}
			})
		}
		<!-- 导航栏的JS-结束 -->
	</script>
	<body>
    <!-- Header Section Start -->
    <div class="header section">

        <!-- Header Top Start -->
        <div class="header-top bg-name-primary">
            <div class="container">
                <div class="row align-items-center">

					<!-- Header Top Message Start -->
					<div class="col-12 col-lg-6">
					    <div class="header-top-msg-wrapper">
					        <a href="index.html" class="header-top-message">欢迎来到萌宠奇遇!</a>
					    </div>
					</div>
					<div class="col-12 col-lg-6">
					    <div class="header-top-settings">
							<a onclick="logout()" style="font-size: small; float: right; color: white;"> 退出登录 </a>
					        <a href="register.html" style="font-size: small; float: right; color: white;"> 注册&nbsp;&nbsp;|&nbsp;&nbsp; </a>
					        <a href="login.html" style="font-size: small; float: right; color: white;"> 登录&nbsp;&nbsp;|&nbsp;&nbsp;</a>
					    </div>
					</div>
					<!-- Header Top Message End -->

                </div>
            </div>
        </div>
        <!-- Header Top End -->

        <!-- Header Bottom Start -->
        <div class="header-bottom">
            <div class="header-sticky">
                <div class="container">
                    <div class="row align-items-center position-relative">

                        <!-- Header Logo Start -->
                        <div class="col-lg-3 col-md-4 col-6">
                            <div class="header-logo">
                                <a href="index.html"><img src="assets/images/logo/logo.png" alt="Site Logo" /></a>
                            </div>
                        </div>
                        <!-- Header Logo End -->

                        <!-- Header Menu Start -->
                        <div class="col-lg-6 d-none d-lg-block">
                            <div class="main-menu">
                                <ul>
                                    <li class="has-children">
                                        <a href="index.html">首页</a>
                                    </li>
                                    <li class="has-children position-static">
                                         <a href="#">萌宠商城</a>
                                        <ul class="mega-menu" id="itemCat">
                                            <li class="mega-menu-col">
                                                <h4 class="mega-menu-title">狗狗</h4>
                                                <ul class="m-b-n10" id="dog">
                                                    
                                                </ul>
                                            </li>
                                            <li class="mega-menu-col">
                                                <h4 class="mega-menu-title">猫咪</h4>
                                                <ul class="m-b-n10" id="cat">
                                                   
                                                </ul>
                                            </li>
                                            <li class="mega-menu-col">
                                                <h4 class="mega-menu-title">其他</h4>
                                                <ul class="m-b-n10" id="other">
                                                   
                                                </ul>
                                            </li>
                                            <li class="mega-menu-col">
                                                <div class="megamenu-image">
                                                    <a href="shop.html">
                                                        <img class="fit-image" src="assets/images/header/mega-menu.png" alt="Megamenu Image">
                                                    </a>
                                                </div>
                                            </li>
                                        </ul>
                                    </li>
                                    <li class="has-children">
                                        <a href="#">萌宠论坛</a>
                                        <ul class="sub-menu">
                                            <li><a href="forum.html">浏览论坛</a></li>
                                            <li><a href="forum-details.html">话题详情</a></li>
                                        </ul>
                                    </li>
                                    <li class="has-children">
                                        <a href="#">萌宠日记</a>
                                        <ul class="sub-menu">
                                            <li><a href="diary.html">我的日记</a></li>
                                            <li><a href="diary-details.html">日记详情</a></li>
                                        </ul>
                                    </li>
                                    <li><a href="login.html">登录</a></li>
                                    <li><a href="register.html">注册</a></li>
                                </ul>
                            </div>
                        </div>
                        <!-- Header Menu End -->

                        <!-- Header Action Start -->
                        <div class="col-lg-3 col-md-8 col-6">
                            <div class="header-actions">

                                <!-- Header Action Search Button Start -->
                                <div class="header-action-btn header-action-btn-search d-none d-md-flex">
                                    <div class="action-execute">
                                        <a class="action-search-open" href="javascript:void(0)"><i class="icon-magnifier icons"></i></a>
                                        <a class="action-search-close" href="javascript:void(0)"><i class="ti-close"></i></a>
                                    </div>
                                    <!-- Search Form and Button Start -->
                                    <form class="header-search-form" >
                                        <input type="text" class="header-search-input" placeholder="搜索商品" value="" id="search">
                                        <button class="header-search-button" onclick="searchItem()"><i class="icon-magnifier icons"></i></button>
                                    </form>
                                    <!-- Search Form and Button End -->
                                </div>
                                <!-- Header Action Search Button End -->

                                <!-- Header My Account Button Start -->
                                <a onclick="accountAuth()" class="header-action-btn header-action-btn-wishlist"">
                                    <i class="icon-user icons"></i>
                                </a>
                                <!-- Header My Account Button End -->

                                <!-- Header Action Button Start -->
                                <div class="header-action-btn header-action-btn-cart d-none d-sm-flex">
                                    <a onclick="cartAuth()" class="cart-visible">
                                        <i class="icon-handbag icons"><span style="font-size: medium;">&nbsp;购物车</span></i>
                                    </a>
                                </div>
                                <!-- Header Action Button End -->
                            </div>
                        </div>
                        <!-- Header Action End -->

                    </div>
                </div>
            </div>
        </div>
        <!-- Header Bottom End -->

    </div>
    <!-- Header Section End -->

		<!-- Breadcrumb Area Start -->
		<div class="section breadcrumb-area bg-name-bright">
			<div class="container">
				<div class="row">
					<div class="col-12 text-center">
						<div class="breadcrumb-wrapper">
							<h2 class="breadcrumb-title">萌宠论坛</h2>
							<ul>
								<li><a href="index.html">主页</a></li>
								<li>萌宠论坛</li>
							</ul>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- Breadcrumb Area End -->
<!--日志-->
		<!-- Shop Section Start -->
		<div class="section section-margin">
			<div class="container">
				<div class="row flex-row-reverse">
					<div class="col-lg-9 col-12">
<!-- 话题概要开始 -->
						<div class="row row-cols-lg-2 row-cols-sm-2 row-cols-1 m-b-n40" id="app">
							<div class="col m-b-40"  v-for="topic in topicList">
							    <!-- Single Blog Start -->
							    <div class="single-blog-wrapper">
							
							        <!-- Blog Thumb Start -->
							        <!-- <div class="blog-thumb thumb-effect">
							            <a class="image" href="forum-details.html">
							                <img class="fit-image" src="assets/images/blog/medium-size/1.jpg" alt="Blog Image">
							            </a>
							        </div> -->
							        <!-- Blog Thumb End -->
									
							        <!-- Blog Content Start -->
							        <div class="blog-content" >
							            <div class="blog-meta">
							                <ul>
							                    <li><span>By</span><a href="#/" v-text="topic.username">阿斯顿</a></li>
							                    <li><span v-text="topic.created">2021/08/23</span></li>
							                </ul>
							            </div>
							            <h2 class="blog-title"><a href="forum-details.html" v-text="topic.title">如何照顾好你的鱼</a></h2>
							            <p v-text="topic.descriptions">鱼既是美丽又有趣的宠物。无论您是初学者还是专家,都有一些重要的鱼类所有权基础知识很重要。通过选择合适的水箱并添加适当的植物和装饰品,确保它们舒适健康...</p>
							            <a class="more-link" @click="convertToComment(topic.id)">查看详情</a>
									<hr />
									<!-- <br /> -->
							        </div>
							        <!-- Blog Content End -->
							    </div>
							    <!-- Single Blog End -->
							</div>
						</div>
<!-- 话题概要结束 -->
<!--日志-->
						<div class="row">
							<div class="col-12 m-t-50">
								<nav class="d-flex justify-content-center">
									<!-- <ul class="pagination">
										<li class="page-item"><a class="page-link active" href="#/">1</a></li>
										<li class="page-item"><a class="page-link" href="#/">2</a></li>
										<li class="page-item"><a class="page-link" href="#/">3</a></li>
										<li class="page-item">
											<a class="page-link rounded-0" href="#/" aria-label="Next">
												<span aria-hidden="true">&raquo;</span>
											</a>
										</li>
									</ul> -->
									<div class="a"></div>
								</nav>
							</div>
						</div>

					</div>
<!--侧边栏-->
					<div class="col-lg-3 col-12">
						<!-- Sidebar Widget Start -->
<!--搜索框开始-->
						<aside class="sidebar_widget m-t-50 mt-lg-0">
							<div class="widget_inner">
								<div class="widget-list m-b-50">
									<h3 class="widget-title m-b-30">搜索&nbsp;</h3>
									<div class="search-box">
										<input type="text" class="form-control" placeholder="搜索内容"
											aria-label="Search Our Store" v-model="queryItemInfo.query">
										<button class="search-icon" type="button">
											<i class="icon-magnifier"></i>
										</button>
									</div>
								</div>
<!--搜索框结束-->
<!--功能模块, 发布话题开始-->
								<div class="widget-list m-b-50">
									<h3 class="widget-title m-b-30">功能模块</h3>
									<div class="sidebar-body">
										<ul class="sidebar-list">
											<li><a href="#/">发布话题</a></li>
										</ul>
									</div>
								</div>
<!--功能模块, 发布话题结束-->
<!--热门话题开始, 根据阅读量排序, 显示前三-->
								<div class="widget-list p-b-50">
									<h3 class="widget-title m-b-30">热门话题</h3>
									<div class="sidebar-body blog-list-wrapper m-b-n30">

										<!-- Single Blog List Start -->
										<div class="single-blog-list m-b-30">

											<!-- Blog List Thumb Start -->
											<div class="blog-thumb">
												<a href="blog-details.html" class="image">
													<img class="fit-image" src="assets/images/blog/small-size/1.jpg"
														alt="Product Image">
												</a>
											</div>
											<!-- Blog List Thumb End -->

											<!-- Blog List Content Start -->
											<div class="blog-list-content">
												<h6 class="blog-name">
													<a href="blog-details.html"
														title="How to take care of your fish">How to take care...</a>
												</h6>
												<div class="blog-meta">
													<p>03/11/2021</p>
												</div>
											</div>
											<!-- Blog List Content End -->

										</div>
										<!-- Single Blog List End -->

										<!-- Single Blog List Start -->
										<div class="single-blog-list m-b-30">

											<!-- Blog List Thumb Start -->
											<div class="blog-thumb">
												<a href="blog-details.html" class="image">
													<img class="fit-image" src="assets/images/blog/small-size/2.jpg"
														alt="Product Image">
												</a>
											</div>
											<!-- Blog List Thumb End -->

											<!-- Blog List Content Start -->
											<div class="blog-list-content">
												<h6 class="blog-name">
													<a href="blog-details.html"
														title="Tips for taking care of dogs">Tips for taking care...</a>
												</h6>
												<div class="blog-meta">
													<p>03/11/2021</p>
												</div>
											</div>
											<!-- Blog List Content End -->

										</div>
										<!-- Single Blog List End -->

										<!-- Single Blog List Start -->
										<div class="single-blog-list m-b-30">

											<!-- Blog List Thumb Start -->
											<div class="blog-thumb">
												<a href="blog-details.html" class="image">
													<img class="fit-image" src="assets/images/blog/small-size/3.jpg"
														alt="Product Image">
												</a>
											</div>
											<!-- Blog List Thumb End -->

											<!-- Blog List Content Start -->
											<div class="blog-list-content">
												<h6 class="blog-name">
													<a href="blog-details.html"
														title="Beginning a Birding Blog">Beginning a Birding...</a>
												</h6>
												<div class="blog-meta">
													<p>12/06/2021</p>
												</div>
											</div>
											<!-- Blog List Content End -->

										</div>
										<!-- Single Blog List End -->

									</div>
								</div>
<!--热门话题结束, 根据阅读量排序, 显示前三-->		
							</div>
						</aside>
						<!-- Sidebar Widget End -->
					</div>
				</div>
			</div>
		</div>
		<!-- Shop Section End -->
<!--侧边栏-->

		<!-- Blog Grid Section End -->

		<!-- Footer Section Start -->
		<footer class="section footer-section">
			<!-- Footer Top Start -->
			<div class="footer-top bg-name-bright section-padding">
				<div class="container">
					<div class="row m-b-n40">
						<div class="col-12 col-sm-6 col-lg-3 m-b-40" data-aos="fade-up" data-aos-duration="1000">
							<div class="single-footer-widget">
								<h1 class="widget-title">关于我们</h1>
								<p class="desc-content">然后疼痛就会停止，疼痛就会受到折磨。</p>
								<!-- Soclial Link Start -->
								<div class="widget-social justify-content-start m-b-n10">
									<a title="Twitter" href="#/"><i class="icon-social-twitter"></i></a>
									<a title="Instagram" href="#/"><i class="icon-social-instagram"></i></a>
									<a title="Linkedin" href="#/"><i class="icon-social-linkedin"></i></a>
									<a title="Skype" href="#/"><i class="icon-social-skype"></i></a>
									<a title="Dribble" href="#/"><i class="icon-social-dribbble"></i></a>
								</div>
								<!-- Social Link End -->
							</div>
						</div>
						<div class="col-12 col-sm-6 col-lg-3 m-b-40" data-aos="fade-up" data-aos-duration="1200">
							<div class="single-footer-widget">
								<h2 class="widget-title">有用的链接</h2>
								<ul class="widget-list">
									<li><a href="wishlist.html">帮助和联系我们</a></li>
									<li><a href="contact.html">退货和退款</a></li>
									<li><a href="contact.html">线上商店</a></li>
									<li><a href="contact.html">条款与条件</a></li>
								</ul>
							</div>
						</div>
						<div class="col-12 col-sm-6 col-lg-3 m-b-40" data-aos="fade-up" data-aos-duration="1400">
							<div class="single-footer-widget">
								<h2 class="widget-title">帮助</h2>
								<ul class="widget-list">
									<li><a href="wishlist.html">愿望清单</a></li>
									<li><a href="contact.html">定价计划</a></li>
									<li><a href="contact.html">物流跟踪</a></li>
									<li><a href="contact.html">退换商品</a></li>
								</ul>
							</div>
						</div>
						<div class="col-12 col-sm-6 col-lg-3 m-b-40" data-aos="fade-up" data-aos-duration="1600">
							<div class="single-footer-widget">
								<h2 class="widget-title">发送时事通讯</h2>
								<div class="widget-body">
									<p class="desc-content m-b-20">订阅我们的时事通讯，首次购买可享受10%的折扣。</p>
									<!-- Newsletter Form Start -->
									<div class="newsletter-form-wrap p-t-5">
										<form id="mc-form" class="mc-form">
											<input type="email" id="mc-email" class="form-control email-box"
												placeholder="demo@example.com" name="EMAIL">
											<button id="mc-submit" class="newsletter-btn" type="submit">发送</button>
										</form>
										<!-- mailchimp-alerts Start -->
										<div class="mailchimp-alerts text-centre">
											<div class="mailchimp-submitting"></div>
											<!-- mailchimp-submitting end -->
											<div class="mailchimp-success text-success"></div>
											<!-- mailchimp-success end -->
											<div class="mailchimp-error text-danger"></div>
											<!-- mailchimp-error end -->
										</div>
										<!-- mailchimp-alerts end -->
									</div>
									<!-- Newsletter Form End -->
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<!-- Footer Top End -->
		</footer>
		<!-- Footer Section End -->

		<script src="assets/js/vendor.min.js"></script>
		<script src="assets/js/plugins.min.js"></script>

		<!--Main JS-->
		<script src="assets/js/main.js"></script>
		<script src="assets/js/page.js"></script>
		
		<script src="assets/jquery-3.6.0.min.js"></script>
		<script src="static/jquery.params.js"></script>
		<script src="static/vue.js"></script>
		<script src="static/axios.min.js"></script>
		<script>
		
			ZUI.paging({
			    prev_next_text: '<|>',
			    count: 20,
			    selector: '.a',
			    current: 16,
			    page_len: 5,
			    color: '#1E9FFF',
			    callBack: function (page) {
			        console.log(page);
			    }
			})

			let app = new Vue({
				el: "#app",
				data: {
					queryItemInfo: {
					  query: '', //定义查询参数
					  pageNum: 1,
					  pageSize: 6
					},
					topicList: [],
					UserList: [],
					user: {
						username: '',
						email: ''
					}
				},
				methods: {
					async findAllTopicList() {
						// alert("获取页面数据")
						// debugger
						let {data: result} = await axios.get("http://localhost:8083/forum/topic/findAllTopicList")
						if(result.status == 200){
							console.log(result.msg)
							for (var i = 0; i < result.data.length; i++) {
								// alert(result.data[i].created)
							}
							this.topicList = result.data
							// 根据用户id查找用户信息
							/* for (var i = 0; i < this.topicList.length; i++) {
								let userId = result.data[i].userId
								this.userList[i] = this.findUserById(userId);
							} */
						}else {
							console.log(result.msg)
						}
					},
					convertToComment(id) {
						window.location.href = `./forum-details.html?id=${id}`
					}
				},
				mounted() {
					this.findAllTopicList()
				}
			})
		</script>
	</body>

</html>
